import cv2
image=cv2.imread('sobel.png',cv2.COLOR_BGR2GRAY)
image=cv2.GaussianBlur(image,(5,5),0)
edges=cv2.Canny(image,50,150)
contours,hierarchy=cv2.findContours(edges,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
n=len(contours)
for i in range(n):
    length=cv2.arcLength(contours[i],True)
    area=cv2.contourArea(contours[i])
    print("轮廓"+str(i)+"的周长:"+str(length))
    print("轮廓" + str(i) + "的面积:" + str(area))
